angular.module("NTApp").factory('RESTService', function($q, $http) {

  function getUrl(sUrl) {
    var baseUrl = "";
    return baseUrl + sUrl;
  }

  function get(url) {
    return $http({
      url: getUrl(url),
      method: 'GET',
      headers: {}
    }).then(function(response) {
      return response;
    }, function(error, status) {
      return $q.reject({
        error: error,
        status: status
      });
    })
  }

  function post(url, data) {
    return $http({
      url: getUrl(url),
      method: 'POST',
      data: data,
      headers: {}
    }).then(function(response) {
      return response;
    }, function(error, status) {
      return $q.reject({
        error: error,
        status: status
      });
    });
  }

  return {
    get: get,
    post: post
  }
});
